/**
 * @author Sebastian
 * @version 2.0
 * @date 2024/7/18 21:41
 */
// 删除排序链表中的重复节点
    //https://leetcode.cn/problems/remove-duplicates-from-sorted-list/
public class Solution83 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) return null;
        ListNode slow = head, fast = head;
        while (fast != null) {
            if (fast.val != slow.val) {
                slow.next = fast;
                slow = slow.next;
            }
            fast = fast.next;
        }
        // 断开后续重复节点
        slow.next = null;
        return head;
    }
}
